package cn.hhchat.weekly.database;

import cn.hhchat.wp.entity.UserEntity;
import cn.hhchat.wp.enums.GradeEnum;
import cn.hhchat.wp.enums.SexEnum;
import cn.hhchat.wp.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

/**
 * Created this one by HMH on 2017/10/22.
 */
@SpringBootTest
@RunWith(SpringRunner.class)
public class CreateUser {

    @Autowired
    UserService userService;

    @Test
    public void createRootUser() {
        UserEntity userEntity = new UserEntity();
        userEntity.setEmail("root@root.com");
        userEntity.setGrade(GradeEnum.研二);
        userEntity.setUsername("root");
        userEntity.setName("root");
        userEntity.setPassword("root");
        userEntity.setSex(SexEnum.男);
        userEntity.setLastPwdChangeDate(new Date());
        userService.save(userEntity);
        System.out.println(userEntity);
    }

}
